package com.cyz.web.app.responsibility.level;

import com.cyz.web.app.responsibility.LeaveRequest;

public abstract class Handler {

    protected final static int LEVEL_ONE = 1;

    protected final static int LEVEL_TWO = 2;

    protected final static int LEVEL_THREE = 3;

    private int startLevel;

    private int endLevel;

    private Handler nextHandler;

    protected abstract void handAnswer(AnswerRequest answerRequest);

    public void setNextHandler(Handler nextHandler) {
        this.nextHandler = nextHandler;
    }

    public Handler(int startLevel, int endLevel) {
        this.startLevel = startLevel;
        this.endLevel = endLevel;
    }


    public final void submit(AnswerRequest answerRequest) {
        this.handAnswer(answerRequest);

        if (answerRequest.getLevel() > this.endLevel) {
            this.nextHandler.submit(answerRequest);
        }else {
            System.out.println("问题处理成功");
        }
    }


}
